<template>
	<view class="">
		<view class="seabx flex justify-center pt-20 pb-20 bg-white align-center" @click="showPopup = true">
			<text class="line-gray mr-20">超过{{searchData.arriveDays}}天未到店</text>
			<u-icon name="arrow-down" color="#aaa" size="16" />
		</view>
		<view class="my-list padding-0 mt-94">
			<u-list :height="swiperHeight" v-if="dataList.length > 0" @scrolltolower="scrolltolower">
				<u-list-item v-for="(item, index) in dataList" :key="item.id">
					<view class="flex align-center bg-white pl-20 pr-20" @click="$u.route('/pages/customer/details',{id: item.id})">
						<view class="shrink0"><u-avatar :src="item.avatarImage" size="46" default-url="/static/logo.png"/></view>
						<view class="flex justify-between align-center w-100 border-b pl-10 ml-14 pt-24 pb-24">
							<view class="">
								<view class="flex">
									<text>{{item.nickName}}</text>
									<u-icon v-if="item.sex!==3" size="15" :name="item.sex===1?'man':'woman'" :color="item.sex===1?'#3c9cff':'#f56c6c'" />
								</view>
								<view class="fsize-26 line-gray mt-10">{{item.gradeName}}</view>
							</view>
							<view @click.stop="phoneCall(item.mobile)">
								<uni-icons custom-prefix="iconfont" type="icon-phone" color="#81c66d" size="30"/>
							</view>
						</view>
					</view>
				</u-list-item>
			</u-list>
		</view>
		<u-empty text="内容为空" mode="data" v-if="dataList.length===0" marginTop="150" />
		<u-popup
			mode="top"
			:show="showPopup"
			:closeOnClickOverlay="true"
			:safeAreaInsetBottom="false"
			@close="showPopup=false"
		>	
			<view class="tagbx pl-30 pr-30 mt-94">
				<text class="fsize-26 line-gray">选择未到店天数</text>
				<view class="mt-20 flex">
					<view class="mr-20" v-for="(tag, tx) in searchList" :key="tag.value">
						<u-tag 
							:text="tag.name" 
							:borderColor="searchData.arriveDays=== tag.value?'#e54d42':'#aaa'"
							:color="searchData.arriveDays === tag.value?'#fff':'#aaa'" 
							:bgColor="searchData.arriveDays === tag.value?'#e54d42':'#fff'"
							shape="circle" 
							size="large" 
							plain
							@click="searchData.arriveDays = tag.value"
						/>
					</view>
				</view>
				<view class="mt-20 width-200">
					<u-input type="number" :value="searchData.arriveDays" @change="setFatalism" shape="circle" inputAlign="center"/>
				</view>
			</view>
			<view class="mt-20 border-t flex">
				<view class="text-align-center border-r width-373 pt-26 pb-26" @click="searchData.arriveDays=20">重置</view>
				<view class="text-align-center line-red width-375 pt-26 pb-26" @click="onSearch">筛选</view>
			</view>
		</u-popup>
	</view>
</template>

<script>	
	import listHeightMixin from '@/common/computedAltitude.js'
	import { mapState } from 'vuex'
	export default {
		mixins:[listHeightMixin],
		data() {
			return {
				showPopup: false,
				searchList: [
					{ name: '20天', value: 20},
					{ name: '30天', value: 30},
					{ name: '40天', value: 40},
				],
				loadMore: false,
				dataList:[],
				searchData:{
					arriveDays: 20,
					page: 1,
					limit: 20
				},
			}
		},
		
		onLoad() {
			this.getPageList()
		},
		computed: {
			...mapState(['userInfo'])
		},
		methods: {
			setFatalism(val){
				this.searchData.arriveDays = val
			},
			onSearch(){
				this.showPopup = false
				this.dataList = []
				this.searchData.page = 1
				this.getPageList()
			},
			getPageList(){
				this.searchData.clientType = this.userInfo.roleCategoryId
				this.$reqPost('GetShareholderUsersPageList', this.searchData).then(res=>{
					this.total = res.otherData.userExpand.userCount
					this.dataList = [...this.dataList, ...res.data]
					if (res.count > this.dataList.length) {
						this.searchData.page++
						this.loadMore = true
					}else {
						this.loadMore = false
					}
				})
			},
			scrolltolower(){
				if(this.loadMore){
					this.getPageList()
				}
			},
		}

	}
</script>

<style lang="scss" scoped>
	.seabx{
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		border-top: 2px #f7f7f7 solid;
		z-index: 10076;
	}
</style>
